home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Interactive 7
/
PC World Interactive 7.iso
/
program
/
cprog.EXE
/
CC_1.ZIP
/
SCLIB.SCR
< prev
next >
Wrap
Text File
|
1980-01-10
|
36KB
|
1,347 lines
.tm 6
.fo left
:gdoc sec= 'IBM Internal Use Only'
:frontm.
:titlep
:title.Small-c I/O and Utility Library
:title.for the IBM Personal Computer
:title.Release 1.05
:title stitle= 'Small-c I/O and Utility Library'.
:author.Daniel. R. Hicks
:address
:aline.RCH38DB(HICKS)
:eaddress
:etitlep
:toc.
:body
:h0.Small-c I/O and Utility Library
.kp on
:h4. abort(status)
:p.Declarations:
:sl compact
:li.int status;
:esl
:p.:hp2.abort:ehp2.
terminates execution of the program and returns to DOS.
:hp2.abort:ehp2. differs from :hp2.exit:ehp2. in that it produces
a diagnostic dump of stack frame addresses (using :hp2.traceback:ehp2.)
before exiting. Like
:hp2.exit:ehp2., :hp2.abort:ehp2. attempts to close open files before
returning to DOS. :hp2.abort:ehp2. does not set the DOS 2.0 return
code.
.kp on
:h4. abs(i)
:p.Declarations:
:sl compact
:li.int i;
:esl
:p.:hp2.abs:ehp2.
returns the absolute value of the integer argument.
.kp on
:h4. assert(expression)
:p.Declarations:
:sl compact
:li.#include <assert.h>
:li.int expression;
:esl
:p.:hp2.assert:ehp2.
causes an :hp2.abort:ehp2. with a diagnostic message when
:hp2.expression:ehp2.
is false.
.kp on
:h4. atoi(nptr)
:p.Declarations:
:sl compact
:li.char *nptr;
:esl
:p.:hp2.atoi:ehp2.
converts the ASCII character string pointed to by
:hp2.nptr:ehp2.
to an integer, interpreting the string as a decimal number. The first
unrecognized character ends the string.
.kp on
:h4. calloc(nelem, elsize)
:p.Declarations:
:sl compact
:li.int nelem, elsize;
:esl
:p.:hp2.calloc:ehp2.
allocates space for an array of
:hp2.nelem:ehp2.
elements of size
:hp2.elsize:ehp2..
The space is initialized to binary zeros.
A null pointer (0) is returned if the space cannot be allocated.
.kp on
:h4. CCARGC()
:p.Declarations:
:sl compact
:esl
:p.:hp2.CCARGC:ehp2.
returns the number of arguments passed to the calling program.
:hp2.CCARGC:ehp2.
works by returning the value in the DL register.
:hp2.CCARGC:ehp2.
must be called before the DL register is modified. The DL register is
modified by a multiply or divide operation or by a call to another function.
.kp on
:h4. clearerr(stream)
:p.Declarations:
:sl compact
:li.FILE *stream;
:esl
:p.:hp2.clearerr:ehp2.
clears the error indicator associated with
:hp2.stream:ehp2..
.kp on
:h4. errno
:p.Declarations:
:sl compact
:esl
:p.:hp2.errno:ehp2.
is an external integer which is set with one of the values defined in
:hp2.errno.h:ehp2.
when an I/O error or system error is detected. This value is NOT cleared when
non-erroneous calls are made.
.kp on
:h4. exit(status)
:p.Declarations:
:sl compact
:li.int status;
:esl
:p.:hp2.exit:ehp2.
terminates execution of the program and returns to DOS.
:hp2.exit:ehp2. differs from :hp2._exit:ehp2. in that it attempts to
close open files before returning to DOS. :hp2.exit:ehp2. does not
set the DOS 2.0 return code.
.kp on
:h4. fbinary(stream)
:p.Declarations:
:sl compact
:li.FILE *stream;
:esl
:p.:hp2.fbinary:ehp2.
causes the named
:hp2.stream:ehp2.
to be processed as a binary file, without performing the CR/LF processing which
is done for text and source files.
.kp on
:h4. fclose(stream)
:p.Declarations:
:sl compact
:li.FILE *stream;
:esl
:p.:hp2.fclose:ehp2.
causes any buffers for the named
:hp2.stream:ehp2.
to be emptied and the file to be closed. Buffers allocated by
the standard I/O system are freed.
:hp2.fclose:ehp2.
is performed automatically upon calling
:hp2.exit:ehp2..
:hp2.EOF:ehp2.
is returned if
:hp2.stream:ehp2.
is not associated with an output file, or if the file is not buffered.
.kp on
:h4. feof(stream)
:p.Declarations:
:sl compact
:li.FILE *stream;
:esl
:p.:hp2.feof:ehp2.
returns non-zero when end of file is read on
:hp2. stream:ehp2.,
otherwise zero.
.kp on
:h4. ferror(stream)
:p.Declarations:
:sl compact
:li.FILE *stream;
:esl
:p.:hp2.ferror:ehp2.
returns non-zero when an error has occurred on
:hp2.stream:ehp2.,
otherwise zero. Unless cleared by
:hp2.clearerr:ehp2.,
the error indication lasts until
:hp2.stream:ehp2.
is closed.
.kp on
:h4. fflush(stream)
:p.Declarations:
:sl compact
:li.FILE *stream;
:esl
:p.:hp2.fflush:ehp2.
causes any buffered data for the named output
:hp2. stream:ehp2.
to be written to that file. The stream remains open.
:hp2.EOF:ehp2.
is returned if
:hp2.stream:ehp2.
is not associated with an output file, or if the file is not buffered.
.kp on
:h4. fgetc(stream)
:p.Declarations:
:sl compact
:li.FILE *stream;
:esl
:p.:hp2.fgetc:ehp2.
returns the next character read from
:hp2.stream:ehp2..
EOF is returned on error or end of file.
.kp on
:h4. fgets(s, n, stream)
:p.Declarations:
:sl compact
:li.char *s;
:li.int n;
:li.FILE *stream;
:esl
:p.:hp2.fgets:ehp2.
reads a string from
:hp2.stream:ehp2.
into the character string addressed by
:hp2.s:ehp2..
Characters are read until a newline character is read or until
:hp2.n-1:ehp2.
characters are read, whichever is first.
The last character placed in s is always followed by a null character.
Unlike
:hp2.gets:ehp2.,
the newline character, if encountered, is placed in s.
.kp on
:h4. fileno(stream)
:p.Declarations:
:sl compact
:li.FILE *stream;
:esl
:p.:hp2.fileno:ehp2.
returns the integer file descriptor (such as returned by
:hp2._open):ehp2.
associated with
:hp2.stream:ehp2..
.kp on
:h4. fopen(filename, type)
:p.Declarations:
:sl compact
:li.char *filename, *type;
:esl
:p.:hp2.fopen:ehp2.
opens the file named by
:hp2.filename:ehp2.
and associates a stream with it.
:hp2.fopen:ehp2.
returns a pointer used to identify the stream in subsequent
operations.
:hp2.type:ehp2.
is a character string having one of the following values:
:dl compact
:dt.r
:dd.Open for reading
:dt.w
:dd.Create for writing
:dt.a
:dd.Open for writing at the end of file (if it exists), or create for
writing
:dt.r+
:dd.Open for read/write and position at the beginning of the file.
:dt.w+
:dd.Open for read/write, truncate the file, and position to the beginning
of it
:dt.a+
:dd.Open for read/write and position at the end of the file.
:edl
:p.:hp2.fopen:ehp2.
returns the pointer
:hp2.NULL:ehp2.
if
:hp2.filename:ehp2.
cannot be accessed.
.kp on
:h4. fprintf(stream, format, [, arg] . . . )
:p.Declarations:
:sl compact
:li.FILE *stream;
:li.char *format;
:esl
:p.:hp2.fprintf:ehp2.
formats the values represented by the
:hp2.arg:ehp2.
arguments and outputs them to
:hp2.stream:ehp2.
according to the format specified by
:hp2.format:ehp2..
format is a character string to be printed which optionally contains
conversion specifications beginning with the character %. Following the
% character is a specification which describes how the corresponding
argument is to be formatted. There must be at least enough arguments
to satisfy the requirements of the format specification.
.kp off
Each conversion specification consists of:
:ul compact
:li.the % character.
:li.an optional minus sign ("-") which specifies left
adjustment of the converted
value within the indicated field.
:li.an optional digit string specifying field width.
If the converted value has
characters than the field width, the field is padded
to the specified width.
Padding is on the left unless a minus sign was used to
specify left adjustment
(and therefore right padding). Padding is with blanks
unless the field width
began with a zero digit, in which case zero-padding is done instead.
:li.an optional period (".") which serves to separate the
field width from the
next digit string.
:li.an optional digit string specifying the maximum number
of characters to be
printed from a string (s-format only).
:li.a character indicating the type of conversion to be performed.
:eul
:p.A field width or maximum string width
value may be replaced with "*" (instead
of the digit string).
This indicates that the next argument is to be interpreted
as the integer field width or maximum string width.
:p.The characters which may be
used for specifying the type of conversion are:
:dl compact
:dt.c
:dd.The character value of the argument is printed.
:dt.d
:dd.The signed integer
value of the argument is printed (-32768 to 32767).
:dt.o
:dd.The unsigned octal
integer value of the argument is printed (0 to 177777).
:dt.s
:dd.The character string addressed by the argument is printed.
:dt.u
:dd.The unsigned integer value of the argument is printed (0 to 65535).
:dt.x
:dd.The unsigned hexadecimal integer value of the argument is printed
(0 to FFFF).
:dt.%
:dd."%" is printed.
:edl
In no case does a small field width value cause truncation of a field; padding
takes place only if the specified field width exceeds the actual width.
.kp on
:h4. fputc(c, stream)
:p.Declarations:
:sl compact
:li.char c;
:li.FILE *stream;
:esl
:p.:hp2.fputc:ehp2.
appends the character :hp2.c:ehp2. to the named output
:hp2.stream:ehp2.. It returns the character written.
If an error occurs, :hp2.EOF:ehp2. is returned.
.kp on
:h4. fputs(s, stream)
:p.Declarations:
:sl compact
:li.char *s;
:li.FILE *stream;
:esl
:p.:hp2.fputs:ehp2.
copies the null-terminated string addressed by
:hp2.s:ehp2.
to
:hp2.stream:ehp2..
Unlike
:hp2.puts:ehp2.,
fputs does not append a newline to the string.
.kp on
:h4. fread(ptr, type, nitems, stream)
:p.Declarations:
:sl compact
:li.char /* or int */ *ptr;
:li.int type, nitems;
:li.FILE *stream;
:esl
:p.:hp2.fread:ehp2.
reads, into a block beginning at
:hp2.ptr, nitems:ehp2.
of data of the type indicated by
:hp2.type:ehp2.,
where type == 1 for char data and type == 2 for int data.
It returns the number of items actually read.
:hp2.fread:ehp2.
returns 0 upon end-of-file or error. If
:hp2.stream:ehp2.
is
:hp2.stdin:ehp2.
or
:hp2.stdout:ehp2.,
then
:hp2.stdout:ehp2.
and
:hp2.stderr:ehp2.
are flushed before any call to
:hp2._read:ehp2.
to satisfy the
:hp2.fread:ehp2..
.kp on
:h4. free(ptr)
:p.Declarations:
:sl compact
:li.char *ptr;
:esl
:p.:hp2.free:ehp2.
deallocates the section of heap storage addressed by :hp2.ptr:ehp2..
:hp2.ptr:ehp2. must contain a value previously obtained from
:hp2.malloc:ehp2. (or :hp2.calloc:ehp2.) or serious damage to the
heap structure can result.
.kp on
:h4. fseek2(stream, offset, ptrname)
:p.Declarations:
:sl compact
:li.FILE *stream;
:li.int offset, ptrname;
:esl
:p.:hp2.fseek2:ehp2.
sets the position of the next input or output operation on
:hp2.stream:ehp2..
The new position is the signed distance
:hp2.offset:ehp2.
bytes from the beginning, the current position, or the end of the
file, for
:hp2.ptrname:ehp2.
values of 0, 1, and 2, respectively.
The new position is the signed distance
(:hp2.offset:ehp2. * 512)
bytes from the beginning, the current position, or the end of the
file, for
:hp2.ptrname:ehp2.
values of 3, 4, and 5, respectively.
:hp2.fseek2:ehp2. undoes any effects of
:hp2.ungetc:ehp2.. :hp2.fseek2:ehp2.
returns -1 for improper seeks.
.kp on
:h4. ftell2(stream, ptrname)
:p.Declarations:
:sl compact
:li.FILE *stream;
:li.int ptrname;
:esl
:p.:hp2.ftell2:ehp2. returns the position within :hp2.stream:ehp2.
which will be used for the next input or output operation.
The value returned is the distance to the current position
from the beginning of the file. If :hp2.ptrname:ehp2. is zero,
then the value is in units of bytes (modulo 65 536). If
:hp2.ptrname:ehp2. is non-zero, then the value is in units of 512
bytes. A value of -1 is returned if :hp2.stream:ehp2. is invalid
for seeks.
.kp on
:h4. fwrite(ptr, type, nitems, stream)
:p.Declarations:
:sl compact
:li.char /* or int */ *ptr;
:li.int type, nitems;
:li.FILE *stream;
:esl
:p.:hp2.fwrite:ehp2.
writes, from a block beginning at
:hp2.ptr, nitems:ehp2.
of data of the type indicated by
:hp2.type:ehp2.,
where type == 1 for char data and type == 2 for int data.
It returns the number of items actually written.
:hp2.fwrite:ehp2.
returns 0 upon error.
.kp on
:hp2.getc(stream)
:p.Declarations:
:sl compact
:li.FILE *stream;
:esl
:p.:hp2.getc:ehp2.
is a macro synonym for
:hp2.fgetc:ehp2..
.kp on
:h4. getchar()
:p.Declarations:
:sl compact
:esl
:p.:hp2.getchar:ehp2.
returns the next character read from stdin.
EOF is returned on error or end of file.
Unlike the standard UNIX version,
getchar is a true function and not a macro.
.kp on
:h4. getparm(string)
:p.Declarations:
:sl compact
:li.char *string;
:esl
:p.:hp2.getparm:ehp2.
returns in the character array addressed by
:hp2.string:ehp2.
the DOS parameter string copied from the DOS program segment prefix.
The array addressed by string should be at least 128 characters long to
handle the worst case.
.kp on
:h4. gets(s)
:p.Declarations:
:sl compact
:li.char *s;
:esl
:p.:hp2.gets:ehp2.
reads a string from stdin
into the character string addressed by
:hp2.s:ehp2..
Characters are read until a newline character is encountered, and, unlike
:hp2.fgets:ehp2.,
the newline character is not placed in s.
The last charact ions:
:sl compact
:li.char c;
:esl
:p.:hp2.isalpha:ehp2.
returns a non-zero value if character
:hp2.c:ehp2.
is a letter (A-Z, upper or lower case). Otherwise, the
value returned is zero. The test assumes the standard ASCII character set.
.kp on
:h4. isascii(c)
:p.Declarations:
:sl compact
:li.char c;
:esl
:p.:hp2.isascii:ehp2.
returns a non-zero value if character
:hp2.c:ehp2.
is a valid ASCII character (value less than 0200 octal). Otherwise, the
value returned is zero.
.kp on
:h4. iscntrl(c)
:p.Declarations:
:sl compact
:li.char c;
:esl
:p.:hp2.iscntrl:ehp2.
returns a non-zero value if character
:hp2.c:ehp2.
is an ASCII control character (value less than 040 octal) or a delete character
(0177 octal). Otherwise, the value returned is zero.
.kp on
:h4. isdigit(c)
:p.Declarations:
:sl compact
:li.char c;
:esl
:p.:hp2.isdigit:ehp2.
returns a non-zero value if character
:hp2.c:ehp2.
is a digit (0-9). Otherwise, the value returned is zero.
The test assumes the standard ASCII character set.
.kp on
:h4. islower(c)
:p.Declarations:
:sl compact
:li.char c;
:esl
:p.:hp2.islower:ehp2.
returns a non-zero value if character
:hp2.c:ehp2.
is a lower case alphabetic character (a-z). Otherwise, the value returned
is zero. The test assumes the standard ASCII character set.
.kp on
:h4. isprint(c)
:p.Declarations:
:sl compact
:li.char c;
:esl
:p.:hp2.isprint:ehp2.
returns a non-zero value if character
:hp2.c:ehp2.
is a printing character: Space (040 octal) through tilde (0176 octal).
Otherwise, the value returned
is zero. The test assumes the standard ASCII character set.
.kp on
:h4. ispunct(c)
:p.Declarations:
:sl compact
:li.char c;
:esl
:p.:hp2.ispunct:ehp2.
returns a non-zero value if character
:hp2.c:ehp2.
is neither a control character nor an alphanumeric character.
Otherwise, the value returned
is zero. The test assumes the standard ASCII character set.
.kp on
:h4. isspace(c)
:p.Declarations:
:sl compact
:li.char c;
:esl
:p.:hp2.isspace:ehp2.
returns a non-zero value if character
:hp2.c:ehp2.
is a space, tab, carriage return, newline, or form feed.
Otherwise, the value returned
is zero. The test assumes the standard ASCII character set.
.kp on
:h4. isupper(c)
:p.Declarations:
:sl compact
:li.char c;
:esl
:p.:hp2.isupper:ehp2.
returns a non-zero value if character
:hp2.c:ehp2.
is a upper case alphabetic character (A-Z). Otherwise, the value returned
is zero. The test assumes the standard ASCII character set.
.kp on
:h4. malloc(size)
:p.Declarations:
:sl compact
:li.int size;
:esl
:p.:hp2.malloc:ehp2. allocates a block of (at least) :hp2.size:ehp2.
bytes from the heap and returns a pointer to the first usable byte.
The space is not initialized to any particular value.
A null pointer (0) is returned if no storage is available.
.kp on
:h4. peekc(seg, offset)
:p.Declarations:
:sl compact
:li.int seg, offset;
:esl
:p.:hp2.peekc:ehp2.
returns the value (sign extended) of the byte at
:hp2.offset:ehp2.
in
:hp2.seg:ehp2.
in the 8088 address space.
.kp on
:h4. perror(s)
:p.Declarations:
:sl compact
:li.char *s;
:esl
:p.:hp2.perror:ehp2.
produces a short error message on stderr describing the error present in
:hp2.errno:ehp2..
First the argument string addressed by
:hp2.s:ehp2.
is printed, then a colon, then the message, and then a newline.
The argument string may be any valid character string, such as the name of
the program encountering the error.
.kp on
:h4. printf(format, [, arg] . . .)
:p.Declarations:
:sl compact
:li.char *format;
:esl
:p.:hp2.printf:ehp2.
formats the values represented by the
:hp2.arg:ehp2.
arguments and prints them according to the format specified by
:hp2.format. format:ehp2.
is a character string to be printed which optionally contains
conversion specifications beginning with the character %. Following the
% character is a specification which describes how the corresponding
argument is to be formatted. There must be at least enough arguments
to satisfy the requirements of the format specification.
.kp off
:p.Each conversion specification consists of:
:ul compact
:li.the % character.
:li. an optional minus sign ("-") which
specifies left adjustment of the converted
value within the indicated field.
:li.an optional digit string specifying
field width. If the converted value has
characters than the field width, the
field is padded to the specified width.
Padding is on the left unless a minus
sign was used to specify left adjustment
(and therefore right padding). Padding
is with blanks unless the field width
began with a zero digit, in which case
zero-padding is done instead.
:li.an optional period (".") which serves
to separate the field width from the
next digit string.
:li.an optional digit string specifying the
maximum number of characters to be
printed from a string (s-format only).
:li.a character indicating the type of conversion to be performed.
:eul
:p.A field width or maximum string
width value may be replaced with "*" (instead
of the digit string). This indicates
that the next argument is to be interpreted
as the integer field width or maximum string width.
:p.The characters which may be
used for specifying the type of conversion are:
:dl compact
:dt.c
:dd.The character value of the argument is printed.
:dt.d
:dd.The signed integer value of the
argument is printed (-32768 to 32767).
:dt.o
:dd.The unsigned octal integer value
of the argument is printed (0 to 177777).
:dt.s
:dd.The character string addressed by the argument is printed.
:dt.u
:dd.The unsigned integer value of the argument is printed (0 to 65535).
:dt.x
:dd.The unsigned hexadecimal integer value of the argument is printed
(0 to FFFF).
:dt.%
:dd."%" is printed.
:edl
:p.In no case does a small field width value
cause truncation of a field; padding
takes place only if the specified field
width exceeds the actual width.
.kp on
:h4. putc(c, stream)
:p.Declarations:
:sl compact
:li.char c;
:li.FILE *stream;
:esl
:p.:hp2.putc:ehp2.
is a macro defining a synonym for the function
:hp2.fputc:ehp2..
.kp on
:h4. putchar(c)
:p.Declarations:
:sl compact
:li.char c;
:esl
:p.:hp2.putchar:ehp2.
appends the character
:hp2.c:ehp2.
to stdout. The value of c is returned unless there is an error, in which case
EOF is returned.
.kp on
:h4. puts(s)
:p.Declarations:
:sl compact
:li.char *s;
:esl
:p.:hp2.puts:ehp2.
copies the null-terminated string
addressed by
:hp2.s:ehp2.
to stdout and (unlike
:hp2.fputs:ehp2.)
appends a newline character.
.kp on
:h4. putw(w, stream)
:p.Declarations:
:sl compact
:li.int w;
:li.FILE *stream;
:esl
:p.:hp2.putw:ehp2.
appends the integer word
:hp2.w:ehp2.
to
:hp2.stream:ehp2..
The value of w is returned unless there is an error, in which case
EOF is returned. However, since EOF is a valid integer,
:hp2.ferror:ehp2.
should be used to test for errors.
.kp on
:h4. rewind(stream)
:p.Declarations:
:sl compact
:li.FILE *stream;
:esl
:p.:hp2.rewind:ehp2.
positions
:hp2.stream:ehp2.
at the beginning of the file.
.kp on
:h4. rindex(s, c)
:p.Declarations:
:sl compact
:li.char *s, c;
:esl
:p.:hp2.rindex:ehp2.
returns a pointer to the last occurrence of character
:hp2.c:ehp2.
in the null-terminated string addressed by
:hp2.s:ehp2.,
or zero if c does not occur in the string.
.kp on
:h4. sprintf(s, format, [, arg] . . . )
:p.Declarations:
:sl compact
:li.char *s, *format;
:esl
:p.:hp2.sprintf:ehp2.
formats the values represented by the
:hp2.arg:ehp2.
arguments and places them in the string addressed by
:hp2.s:ehp2.
according to the format specified by
:hp2.format:ehp2..
format is a character string to be printed which optionally contains
conversion specifications beginning with the character %. Following the
% character is a specification which describes how the corresponding
argument is to be formatted. There must be at least enough arguments
to satisfy the requirements of the format specification.
.kp off
Each conversion specification consists of:
:ul compact
:li.the % character.
:li.an optional minus sign ("-") which specifies left
adjustment of the converted value within the indicated
field.
:li.an optional digit string specifying field width. If the
converted value has characters than the field width, the
field is padded to the specified width. Padding is on the
left unless a minus sign was used to specify left adjustment
(and therefore right padding). Padding is with blanks
unless the field width began with a zero digit, in which
case zero-padding is done instead.
:li.an optional period (".") which serves to separate the
field width from the next digit string.
:li.an optional digit string specifying the maximum number of
characters to be printed from a string (s-format only).
:li.a character indicating the type of conversion to be performed.
:eul
:p.A field width or maximum string width value may be replaced
with "*" (instead of the digit string). This indicates that
the next argument is to be interpreted as the integer field
width or maximum string width.
:p.The characters which may be used for specifying the type of
conversion are:
:dl compact
:dt.c
:dd.The character value of the argument is printed.
:dt.d
:dd.The signed integer value of the argument
is printed (-32768 to 32767).
:dt.o
:dd.The unsigned octal integer value of the
argument is printed (0 to 177777).
:dt.s
:dd.The character string addressed by the argument is printed.
:dt.u
:dd.The unsigned integer value of the argument is printed (0 to 65535).
:dt.x
:dd.The unsigned hexadecimal integer value of the argument is printed
(0 to FFFF).
:dt.%
:dd."%" is printed.
:edl
:p.In no case does a small field width value cause truncation of
a field; padding takes place only if the specified field
width exceeds the actual width.
.kp on
:h4. strcat(s1, s2)
:p.Declarations:
:sl compact
:li.char *s1, *s1;
:esl
:p.:hp2.strcat:ehp2.
appends a copy of the null-terminated string addressed by
:hp2.s2:ehp2.
to the end of the null-terminated string addressed by
:hp2.s1:ehp2..
The function returns s1.
.kp on
:h4. strcmp(s1, s2)
:p.Declarations:
:sl compact
:li.char *s1, *s2;
:esl
:p.:hp2.strcmp:ehp2.
compares the null-terminated strings addressed
by the two arguments, and returns a result which
is greater than, equal to, or less than zero, if string
:hp2.s1:ehp2.
is greater than, equal to, or less than string
:hp2.s2:ehp2.,
respectively.
.kp on
:h4. strcpy(s1, s2)
:p.Declarations:
:sl compact
:li.char *s1, *s2;
:esl
:p.:hp2.strcpy:ehp2.
copies the null-terminated string addressed by
:hp2.s2:ehp2.
to the location addressed by
:hp2.s1:ehp2..
The function returns the pointer s1.
.kp on
:h4. strlen(s)
:p.Declarations:
:sl compact
:li.char *s;
:esl
:p.:hp2.strlen:ehp2.
returns the length of the null-terminated string addressed by
:hp2.s:ehp2..
.kp on
:h4. strncat(s1, s2, n)
:p.Declarations:
:sl compact
:li.char *s1, *s1;
:esl
:p.:hp2.strncat:ehp2.
appends a copy of the null-terminated string addressed by
:hp2.s2:ehp2.
to the end of the null-terminated string addressed by
:hp2.s1. At most:ehp2.,
:hp2.n:ehp2.
characters are appended.
The function returns s1.
.kp on
:h4. strncmp(s1, s2, n)
:p.Declarations:
:sl compact
:li.char *s1, *s2;
:esl
:p.:hp2.strncmp:ehp2.
compares the null-terminated strings addressed
by the two arguments, and returns a result which
is greater than, equal to, or less than zero, if string
:hp2.s1:ehp2.
is greater than, equal to, or less than string
:hp2.s2:ehp2.,
respectively. At most,
:hp2.n:ehp2.
characters are compared.
.kp on
:h4. strncpy(s1, s2, n)
:p.Declarations:
:sl compact
:li.char *s1, *s2;
:esl
:p.:hp2.strncpy:ehp2.
copies the null-terminated string addressed by
:hp2.s2:ehp2.
to the location addressed by
:hp2.s1:ehp2..
Exactly
:hp2.n:ehp2.
characters are copied, with the string being truncated or null padded as
necessary. Note that if the length of the string is greater than or equal
to n, the resulting string will not be null terminated.
The function returns the pointer s1.
.kp on
:h4. swab(from, to, nbytes)
:p.Declarations:
:sl compact
:li.char *from, *to;
:li.int nbytes;
:esl
:p.:hp2.swab:ehp2.
copies
:hp2.nbytes:ehp2.
bytes from the location addressed by
:hp2.from:ehp2.
to the location addressed by
:hp2.to:ehp2.,
exchanging adjacent odd and even bytes. nbytes should be even.
.kp on
:h4. sys_errlist
:p.Declarations:
:sl compact
:esl
:p.:hp2.sys_errlist:ehp2.
is the external name of a table of error messages corresponding to the values
in errno.h. sys_errlist is a vector of integers, each of which can be cast
into a character pointer and used to address a null-terminated string containing
the corresponding error message.
:hp2.sys_nerr:ehp2.
is the external name of an integer value specifying the number of entries in
sys_errlist.
.kp on
:h4. sys_nerr
:p.Declarations:
:sl compact
:esl
:p.:hp2.sys_nerr:ehp2.
is the external name of the integer value specifying the number of entries in
sys_errlist.
.kp on
:h4. tolower(c)
:p.Declarations:
:sl compact
:li.char c;
:esl
:p.:hp2.tolower:ehp2.
returns the value the character
:hp2.c:ehp2.,
converted to lower-case if the original character was an upper-case alphabetic.
The standard ASCII character set is assumed.
.kp on
:h4. toupper(c)
:p.Declarations:
:sl compact
:li.char c;
:esl
:p.:hp2.toupper:ehp2.
returns the value the character
:hp2.c:ehp2.,
converted to upper-case if the original character was a lower-case alphabetic.
The standard ASCII character set is assumed.
.kp on
:h4. traceback(stream)
:p.Declarations:
:sl compact
:li.FILE *stream;
:esl
:p.:hp2.traceback:ehp2.
produces a debug display of stack frame addresses and return addresses for the
currently executing program. This can be used (in conjunction with a LINK MAP
and other dumps) to determine the current state of the program as well as its
call history.
.kp on
:h4. ungetc(c, stream)
:p.Declarations:
:sl compact
:li.char c;
:li.FILE *stream;
:esl
:p.:hp2.ungetc:ehp2.
pushes character
:hp2.c:ehp2.,
back on
:hp2.stream:ehp2..
The pushed character will be returned by the next call to
:hp2.fgetc:ehp2.
for
:hp2.stream. Only one character may be pushed back:ehp2..
The function returns the character c, unless an error condition is detected,
in which case EOF is returned.
fseek2 erases the pushed character.
.kp on
:h4. _close(fildes)
:p.Declarations:
:sl compact
:li.int fildes;
:esl
:p.:hp2._close:ehp2.
closes the file identified by
:hp2.fildes:ehp2..
All files are closed automatically upon
:hp2.exit:ehp2.
(except in certain error cases) but the explicit use of
:hp2._close:ehp2.
may be necessary if many files are used by a program, since there is a limit to
the number of simultaneously open files.
.kp on
:h4. _create(name, mode)
:p.Declarations:
:sl compact
:li.char *name;
:li.int mode;
:esl
:p.:hp2._create:ehp2.
creates a new file or prepares to rewrite an existing file with the name
specified by the string addressed by
:hp2.name. mode:ehp2.
specifies the attributes given to the file if a new one is created. mode is
bit significant, with 0x02 specifying "system", and 0x04 specifying "hidden".
.kp on
:h4. _doschar(ch)
:p.Declarations:
:sl compact
:li.char ch;
:esl
:p.:hp2._doschar:ehp2.
determines if character
:hp2.ch:ehp2.
is a legal DOS filename character (DOS 2.0 rules). Legal characters are
"a"-"z", "A"-"Z", "0"-"9", and "$@!%'()-{}_^~`".
.kp on
:h4. _dosdate(year, month, day)
:p.Declarations:
:sl compact
:li.int *year, *month, *day;
:esl
:p.:hp2._dosdate:ehp2.
returns the current date (as supplied by DOS). The year is returned in the
location addressed by
:hp2.year:ehp2.,
the month is returned in the location addressed by
:hp2.month:ehp2.,
and the day is returned in the location addressed by
:hp2.day:ehp2..
.kp on
:h4. _dosfcall(function, dreg)
:p.Declarations:
:sl compact
:li.#include <doscall.h>
:li.int function, dreg;
:esl
:p.:hp2._dosfcall:ehp2.
performs an INT 21H function call with
:hp2.function:ehp2.
as the function code, and
:hp2.dreg:ehp2.
as the DX register value. The contents of AL are returned (signed extended).
.kp on
:h4. _dosfxcall(function, dreg, cin, cout)
:p.Declarations:
:sl compact
:li.#include <doscall.h>
:li.int function, dreg, cin, *cout;
:esl
:p.:hp2._dosfxcall:ehp2.
performs an INT 21H function call with
:hp2.function:ehp2.
as the function code,
:hp2.dreg:ehp2.
as the DX register value, and
:hp2.cin:ehp2.
as the CX register value.
The contents of AL are returned (signed extended) as the value of the function,
and the contents of CX are returned in the location addressed by pointer
:hp2.cout:ehp2..
.kp on
:h4. _dostime(hours, minutes, seconds, hundredths)
:p.Declarations:
:sl compact
:li.int *hours, *minutes, *seconds, *hundredths;
:esl
:p.:hp2._dostime:ehp2.
returns the current time (as supplied by DOS). The hour is returned in the
location addressed by
:hp2.hours:ehp2.,
the minute is returned in the location addressed by
:hp2.minutes:ehp2.,
and the second is returned in the location addressed by
:hp2.seconds:ehp2..
The location addressed by
:hp2.hundredths:ehp2.
contains the fraction of a second in units of 1/100th of a second.
.kp on
:h4. _exit(status)
:p.Declarations:
:sl compact
:li.int status;
:esl
:p.:hp2._exit:ehp2.
terminates execution of the program and returns to DOS.
:hp2._exit:ehp2. differs from :hp2.exit:ehp2. in that it does not
close open files before returning to DOS. Neither function sets the
DOS 2.0 return code.
.kp on
:h4. _ioctl(fildes, request, argp)
:p.Declarations:
:sl compact
:li.#include <sgtty.h>
:li.int fildes, request;
:li.char *argp;
:esl
:p.:hp2._ioctl:ehp2.
changes the mode of operation of the device or file specified by
:hp2.fildes:ehp2..
The implemented values for
:hp2.request:ehp2.
are:
:dl compact
:dt.TIOCSETP:dd.set parameters
:dt.TIOCGETP:dd.get parameters
:edl
:p.:hp2.argp:ehp2.
addresses the 6-character structure defined by sgtty.h. The 5th byte, SG_FLGS,
contains the only significant attributes. It is defined as follows (octal):
:dl compact
:dt.EVENP :dd.200 Even parity allowed on input.
:dt.ODDP :dd.100 Odd parity allowed on input.
:dt.RAW :dd.040 Raw mode:
Wake up on all characters & return control characters.
:dt.CRMOD :dd.020 Map CR/LF to NL and back; echo LF or CR as CR-LF.
:dt.ECHO :dd.010 Echo typed characters.
:dt.LCASE :dd.004 Map upper case to lower case.
:dt.CBREAK :dd.002 Return each character as soon as typed.
:edl
:p.The modes which can be affected control such things as
buffering, echoing, etc. One important attribute which can be
controlled with _ioctl is the mapping of CR/LF to NL and back
for C-DOS compatibility.
.kp on
:h4. _isatty(fildes)
:p.Declarations:
:sl compact
:li.int fildes;
:esl
:p.:hp2._isatty:ehp2.
returns a non-zero value if the file described by
:hp2.fildes:ehp2.
is a terminal device (or printer), zero otherwise.
.kp on
:h4. _open(name, mode)
:p.Declarations:
:sl compact
:li.char *name;
:li.int mode;
:esl
:p.:hp2._open:ehp2.
opens the file with the name addressed by
:hp2.name. mode:ehp2.
determines whether the file is opened for reading (mode == 0), writing (mode ==
1), or reading and writing (mode == 2). The file is positioned at the beginning
of the file.
.kp on
:h4. _read(fildes, buffer, nbytes)
:p.Declarations:
:sl compact
:li.int fildes, nbytes;
:li.char *buffer;
:esl
:p.:hp2._read:ehp2.
reads up to the next
:hp2.nbytes:ehp2.
of data from the file selected by
:hp2.fildes:ehp2.
and places them in the location defined by
:hp2.buffer:ehp2..
Fewer than nbytes may be read, if end-of-file is encountered or if the file
is a device such as a terminal. The number of bytes read is returned. If
nbytes is zero, then end-of-file has been reached and there are no bytes to
read.
.kp on
:h4. _seek(fildes, offset, whence)
:p.Declarations:
:sl compact
:li.int fildes, offset, whence;
:esl
:p.:hp2._seek:ehp2.
causes the file identified by
:hp2.fildes:ehp2.
to be positioned at the location specified by
:hp2.offset:ehp2.
and
:hp2.whence:ehp2..
The returned value is the resulting location. The result of seeking beyond the
end of the file is undefined. The values of whence work as follows:
:dl compact
:dt.0 :dd.The pointer is set to offset
:dt.1 :dd.The pointer is set to the current location plus offset
:dt.2 :dd.The pointer is set to the size of the file plus offset
:dt.3 :dd.The pointer is set to offset * 512
:dt.4 :dd.The pointer is set to the current location plus offset * 512
:dt.5 :dd.The pointer is set to the size of the file plus offset * 512
:edl
:p.The whence values of 3, 4, and 5 are necessary since offset can
only take values of +/- 32k, and DOS files can be larger than
this. Using two invocations of _seek, files of up to 16 MB can
be positioned to any arbitrary byte. First use a whence of 3,
4, or 5, to position within 512 bytes of the desired location,
then use a whence of 1 to position to the exact byte.
.kp on
:h4. _write(fildes, buffer, nbytes)
:p.Declarations:
:sl compact
:li.int fildes, nbytes;
:li.char *buffer;
:esl
:p.:hp2._write:ehp2.
takes the next
:hp2.nbytes:ehp2.
of data from the location defined by
:hp2.buffer:ehp2.,
and writes them in the file defined by
:hp2.fildes:ehp2..
The number of characters actually written is returned, and an error was
encountered if this value is not equal to nbytes.
.kp off
:egdoc